<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登录</title>
</head>
<body>
    <p>在线调试工具--打开管理台：</p>
    <input type="button" value="打开远程控制台" style="color:red;" baseUrl="" onclick="javascript:doSubmit();"/><br /><br />
	
  
  <form method="POST" action="" target="_blank" id="post_form" style="display:none;">
    <input type="hidden" name="token" id="token" />
  </form>
  

<script type="text/javascript">
let localKey  = "";
let baseUrl   = "http://url:point";
let tarAction = "/arrival.html";

let scriptNode = document.createElement("SCRIPT");
scriptNode.setAttribute("type","text/javascript");
scriptNode.setAttribute("src",baseUrl+"/assets/md5/md5.js");
document.head.append(scriptNode);


scriptNode = document.createElement("SCRIPT");
scriptNode.setAttribute("type","text/javascript");
scriptNode.setAttribute("src",baseUrl+"/assets/des/crypto-js.min.js");
document.head.append(scriptNode);



function doSubmit(node,keyId){
  let day        = now();
  let md5Code    = md5(localKey).toUpperCase();
  let actionName = md5(md5Code+day+md5Code).toUpperCase()+".ha";
  let form       = document.getElementById("post_form");

  let keyHex = CryptoJS.enc.Utf8.parse("/"+actionName);
  let encrypted = CryptoJS.DES.encrypt(tarAction, keyHex, {
      mode:    CryptoJS.mode.ECB,
      padding: CryptoJS.pad.Pkcs7
  });

  let encTarAction = encrypted.ciphertext.toString();
  form.action    = baseUrl+"/"+actionName+"?"+encTarAction+"&redir=1";
  document.getElementById("token").value = localKey;
  form.submit();
}


//#region now()
function now() {
  let nowDate = new Date()
  let year = nowDate.getFullYear()
  let month = nowDate.getMonth() + 1
  let day = nowDate.getDate()
  if (month < 10) month = '0' + month
  if (day < 10) day = '0' + day
  return year + '-' + month + '-' +day
}
//#endregion
 

</script>
</body>
</html>

